<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Oauth2 Login</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<nav class="navbar navbar-light bg-light">
    <div class="container-fluid">
        <div class="navbar-brand d-inline-flex">
            <img src="https://cdn.smart7.tech/static/img/Perfect7.png" alt=""
                 style="width: 2.5rem;height: 2.5rem;"
                 class="d-inline-block align-text-top">
            <span class="my-auto mx-3">Axum_test apps</span>
        </div>
    </div>
</nav>
<div class="container" style="height: 100vh;">
    <div class="row justify-content-center" style="height: 80%;">
        <div class="col col-md-6 align-self-center">
            <div class="card border-0">
                <img src="{{ icon }}" class="img-thumbnail rounded mx-auto d-block" style="width: 10rem;height: 10rem;"
                     alt="{{ name }}">
                <div class="card-body">
                    <div class="row">
                        <h5 class="card-title text-center fs-1">{{ name }}</h5>
                    </div>
                    <form class="row" name="login_form">
                        <div class="mb-3">
                            <label for="username" class="form-label">账 户: </label>
                            <input type="text" class="form-control" id="username" name="username">
                        </div>
                        <div class="mb-3">
                            <label for="password" class="form-label">密 码: </label>
                            <input type="password" class="form-control" id="password" name="password">
                        </div>
                        <div class="mb-3">
                            <button class="btn btn-primary form-control" type="button" onclick="on_submit()">登 陆
                            </button>
                            <div id="emailHelp" class="form-text">登陆表示您对<b>{{ name }}</b>应用进行授权访问您账户相关信息
                            </div>
                        </div>

                        <script type="text/javascript">
                            on_submit()

                            function on_submit() {
                                var obj = {};
                                obj.username = document.login_form.username.value;
                                obj.password = document.login_form.password.value;
                                $.post("",
                                    obj,
                                    function (data, status) {
                                        console.log("数据: " + data.data + "状态: " + status);
                                        if (data.data) {
                                            location.replace(data.data);
                                        }
                                    });
                            }</script>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>